
/**
 * Audio Helper.
 *
 * Released under Apache License, Version 2.0.
 */

package bsp.android;

import java.io.IOException;

import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.media.MediaPlayer;

public class AudioHelper
{	
	protected AudioHelper()
	{
		/* empty by design */
	}
	
	public static void playSound(Context context, MediaPlayer mp, String filename)
	{
		mp.reset();
		AssetFileDescriptor afd;
		try {
			afd = context.getAssets().openFd(filename);
			mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
			mp.prepare();
			mp.start();
		} catch (IOException e) {
			e.printStackTrace();
		} 
	}
}

/* end */
